<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>PHP相关 | 邢万江</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="学生信息管理系统基本功能 学生添加功能 展示学生信息功能 删除学生信息  实现思路注册功能 1. 获取前端表单传递数据 2. 获取前端传递图片，并保存在服务器中 3. 将表单的数据和上传图片的地址 保存在数据库中 4. 页面跳转到列表页 5.跳转用header(&amp;apos;location:01-list.php&amp;apos;)向data.txt中保存数据的过程： 1234561-用一维数组存放 获">
<meta property="og:type" content="article">
<meta property="og:title" content="PHP相关">
<meta property="og:url" content="http://yoursite.com/2019/05/06/PHP%E7%9B%B8%E5%85%B3/index.html">
<meta property="og:site_name" content="邢万江">
<meta property="og:description" content="学生信息管理系统基本功能 学生添加功能 展示学生信息功能 删除学生信息  实现思路注册功能 1. 获取前端表单传递数据 2. 获取前端传递图片，并保存在服务器中 3. 将表单的数据和上传图片的地址 保存在数据库中 4. 页面跳转到列表页 5.跳转用header(&amp;apos;location:01-list.php&amp;apos;)向data.txt中保存数据的过程： 1234561-用一维数组存放 获">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="e:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/http1.png">
<meta property="og:image" content="e:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/mysqlcmd01.png">
<meta property="og:image" content="e:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/cmd.png">
<meta property="og:image" content="e:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/connect.png">
<meta property="og:image" content="e:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/createtable.png">
<meta property="og:image" content="e:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/savetable.png">
<meta property="og:image" content="e:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/addtable.png">
<meta property="article:published_time" content="2019-05-05T16:00:00.000Z">
<meta property="article:modified_time" content="2020-05-19T01:07:22.586Z">
<meta property="article:author" content="程序猿">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="e:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/http1.png">
  
    <link rel="alternative" href="/atom.xml" title="邢万江" type="application/atom+xml">
  
  
    <link rel="icon" href="/http://oayoilchh.bkt.clouddn.com/2016/07/27/18:05:26%20">
  
  
      
<link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">

  
  
<link rel="stylesheet" href="/css/style.css">

  <link rel="stylesheet" href="/font-awesome/css/font-awesome.min.css">
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
  
  
      <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  
  <!-- 加载特效 -->
    <script src="/js/pace.js"></script>
    <link href="/css/pace/pace-theme-flash.css" rel="stylesheet" />
  <script>
      var yiliaConfig = {
          rootUrl: '/',
          fancybox: true,
          animate: true,
          isHome: false,
          isPost: true,
          isArchive: false,
          isTag: false,
          isCategory: false,
          open_in_new: false
      }
  </script>
<meta name="generator" content="Hexo 4.2.1"></head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <script src="http://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
        <a href="/" class="profilepic">
            
            <img lazy-src="img/head.jpg" class="js-avatar">
            
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">程序猿</a></h1>
        </hgroup>
        
        
            <form>
                <input type="text" class="st-default-search-input search" id="local-search-input" placeholder="搜索一下" autocomplete="off">
            </form>
            <div id="local-search-result"></div>
        
        
            <script type="text/javascript">
                (function() {
                    'use strict';
                    function getMatchData(keyword, data) {
                        var matchData = [];
                        for(var i =0;i<data.length;i++){
                            if(data[i].title.toLowerCase().indexOf(keyword)>=0) 
                                matchData.push(data[i])
                        }
                        return matchData;
                    }
                    var $input = $('#local-search-input');
                    var $resultContent = $('#local-search-result');
                    $input.keyup(function(){
                        $.ajax({
                            url: '/search.json',
                            dataType: "json",
                            success: function( json ) {
                                var str='<ul class=\"search-result-list\">';                
                                var keyword = $input.val().trim().toLowerCase();
                                $resultContent.innerHTML = "";
                                if ($input.val().trim().length <= 0) {
                                    $resultContent.empty();
                                    $('#switch-area').show();
                                    return;
                                }
                                var results = getMatchData(keyword, json);
                                if(results.length === 0){
                                    $resultContent.empty();
                                    $('#switch-area').show();
                                    return;
                                } 
                                for(var i =0; i<results.length; i++){
                                    str += "<li><a href='"+ results[i].url +"' class='search-result-title'>"+ results[i].title +"</a></li>";
                                }
                                str += "</ul>";
                                $resultContent.empty();
                                $resultContent.append(str);
                                $('#switch-area').hide();
                            }
                        });
                    });
                })();
            </script>
        
        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        
        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a  href="http://bestwing.me" target="_blank" rel="noopener">博客首页</a></li>
                        
                            <li><a  href="/archives">文章归档</a></li>
                        
                            <li><a  href="/CTFStudy">学习导航</a></li>
                        
                            <li><a  href="/PWNABLE">PWNABLE</a></li>
                        
                            <li><a  href="/resume">个人简历</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fl mail"  target="_blank" href="/760996296@qq.com" title="mail">mail</a>
                            
                                <a class="fl github"  target="_blank" href="https://github.com/xingwanjiang" title="github">github</a>
                            
                                <a class="fl zhihu"  target="_blank" href="https://www.baidu.com/people/Swings" title="zhihu">zhihu</a>
                            
                                <a class="fl weibo"  target="_blank" href="https://weibo.com/u/7346457923/home?wvr=5" title="weibo">weibo</a>
                            
                                <a class="fl rss"  target="_blank" href="/atom.xml" title="rss">rss</a>
                            
                        </ul>
                    </nav>
                </section>
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        
                    </div>
                </section>
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://ring3.xyz/">Yllen</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://mxny.org/">麦香浓郁</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://whereisk0shl.top/">K0sh1</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://www.ycjcl.cc/">信鑫</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://bystudent.com/">ByStundet表哥</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="https://www.jarviswang.me/">汪神_Jarvis</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://sh3ll.me/">Chu</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="https://www.hackfun.org/">4ido10n</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://www.cnblogs.com/iamstudy">L3m0n</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://o0xmuhe.me/">muhe</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://blog.nuptzj.cn/">_画船听雨</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://www.virzz.com/index.html">Virink</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://www.sqlsec.com/">国光</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://www.bodkin.ren/">老锥</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://www.cizel.cn/">C1zel</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://1phan.cc">1phan</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="https://www.liuil.top/">liuil</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://www.cnblogs.com/Ox9A82/">Ox9A82</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://burnegg.com/">burnegg</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="https://jwrsec.cn/">jwr-sec</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://sudalover.cn/">苏打</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://blog.binklac.com">VeroFess</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://www.bendawang.site/">bendawang</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://weeklyalgo.codes/">hook</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://www.flier.net.cn/">Flier&#39;blog</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://www.mutepig.club">mutepig</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="https://blog.iret.xyz/list.aspx">Silver</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://simp1e.leanote.com/">Simple</a>
                    
                      <a target="_blank"  class="main-nav-link switch-friends-link" href="http://processor.pub/">Processor</a>
                    
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">一只淹死在二进制海洋里的二进制狗</div>
                </section>
                
            </div>
        </div>
    </header>
</div>

    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="Me">程序猿</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                
                    <img lazy-src="/img/head.jpg" class="js-avatar">
                
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="Me">程序猿</a></h1>
            </hgroup>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="http://bestwing.me" target="_blank" rel="noopener">博客首页</a></li>
                
                    <li><a href="/archives">文章归档</a></li>
                
                    <li><a href="/CTFStudy">学习导航</a></li>
                
                    <li><a href="/PWNABLE">PWNABLE</a></li>
                
                    <li><a href="/resume">个人简历</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                <div class="social">
                    
                        <a class="mail" target="_blank" href="/760996296@qq.com" title="mail">mail</a>
                    
                        <a class="github" target="_blank" href="https://github.com/xingwanjiang" title="github">github</a>
                    
                        <a class="zhihu" target="_blank" href="https://www.baidu.com/people/Swings" title="zhihu">zhihu</a>
                    
                        <a class="weibo" target="_blank" href="https://weibo.com/u/7346457923/home?wvr=5" title="weibo">weibo</a>
                    
                        <a class="rss" target="_blank" href="/atom.xml" title="rss">rss</a>
                    
                </div>
            </nav>
        </header>                
    </div>
</nav>
      <div class="body-wrap"><article id="post-PHP相关" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2019/05/06/PHP%E7%9B%B8%E5%85%B3/" class="article-date">
      <time datetime="2019-05-05T16:00:00.000Z" itemprop="datePublished">2019-05-06</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      PHP相关
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        

        
        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <h1 id="学生信息管理系统"><a href="#学生信息管理系统" class="headerlink" title="学生信息管理系统"></a>学生信息管理系统</h1><h3 id="基本功能"><a href="#基本功能" class="headerlink" title="基本功能"></a>基本功能</h3><ul>
<li>学生添加功能</li>
<li>展示学生信息功能</li>
<li>删除学生信息</li>
</ul>
<h3 id="实现思路"><a href="#实现思路" class="headerlink" title="实现思路"></a>实现思路</h3><p>注册功能</p>
<pre><code>1. 获取前端表单传递数据
2. 获取前端传递图片，并保存在服务器中
3. 将表单的数据和上传图片的地址 保存在数据库中
4. 页面跳转到列表页
5.跳转用header(&apos;location:01-list.php&apos;)</code></pre><p>向data.txt中保存数据的过程：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">1-用一维数组存放 获取的 学生数据</span><br><span class="line">2.从data.txt中取出字符串形式学生数据</span><br><span class="line">3.将字符串数据转成二维数组</span><br><span class="line">4.向二维数组中添加 学生数据（array_push(数组，追加的项)或者$arr[]&#x3D;$info）</span><br><span class="line">5.把二维数组转成字符串</span><br><span class="line">6.把字符串中的数据 存储到data.txt中</span><br></pre></td></tr></table></figure>



<p>注意：</p>
<pre><code>我们目前没有学习数据库，使用txt记事本来模拟，实现思路：
1. 存储一个人的信息使用一维数组
2. 存储一个班的信息要使用二维数组
3. 数组是一个变量，页面关闭后，数据会销毁，下次打开页面后，数据不存在了
4. 为了数据能永久存储，把数据存储到txt文件中
5. 班级学生信息存放在二维数组中，添加和删除学生信息，就是对二维数组进行追加和删除，对二维数组操作完成后，再把二维数组存储到data.txt
6.跳转用header(&apos;location:01-list.php&apos;)</code></pre><p>展示功能</p>
<pre><code>1.获取txt记事本中的学生数据字符串，转成二维数组
2.动态遍历渲染在页面中</code></pre><p>删除功能</p>
<pre><code>1.获取要删除学生id,
2.从data.txt中取出字符串形式学生数据
3.将字符串数据转成二维数组
4.根据id，从二维数组中删除指定索引的元素
5.把二维数组转成字符串
6.把字符串中的数据 存储到data.txt中
7.删除数组用array_splice(数组，从哪开始删，删几个，)</code></pre><h1 id="HTTP协议"><a href="#HTTP协议" class="headerlink" title="HTTP协议"></a>HTTP协议</h1><p><strong>协议：</strong></p>
<blockquote>
<p>协议，就是事先的一种约定、规则、规范、标准。</p>
</blockquote>
<p> <strong>常见协议</strong></p>
<ul>
<li>HTTP、HTTPS 超文本传输协议 </li>
<li>FTP 文件传输协议</li>
<li>SMTP 简单邮件传输协议</li>
</ul>
<p><strong>HTTP协议</strong></p>
<p>HTTP协议即超文本传输协议,  是一个 [浏览器端] 和 [服务器端] 请求和响应的标准</p>
<ul>
<li>常用请求方法  GET, POST</li>
</ul>
<ul>
<li>请求 (request)：<code>请求行、请求头、请求主体</code>。</li>
</ul>
<ul>
<li>响应 (response)：<code>状态行、响应头、响应主体</code>。</li>
</ul>
<p><img src="E:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/http1.png" alt=""></p>
<h3 id="请求报文和响应报文"><a href="#请求报文和响应报文" class="headerlink" title="请求报文和响应报文"></a>请求报文和响应报文</h3><p><strong>请求/请求报文</strong></p>
<p>​    请求由客户端发起，其规范格式为：请求行、请求头、请求主体。    </p>
<p><strong>响应/响应报文</strong></p>
<p>​    响应由服务器发出，其规范格式为：状态行、响应头、响应主体。</p>
<p><strong>get请求的请求报文详解</strong> </p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//--------------------------请求行--------------------------------</span></span><br><span class="line"><span class="comment">// GET  请求方式</span></span><br><span class="line"><span class="comment">// /day02/01.php?username=pp&amp;password=123456    请求路径+参数（注意点）</span></span><br><span class="line"><span class="comment">// HTTP/1.1 HTTP的版本号</span></span><br><span class="line">GET /day02/<span class="number">01.</span>php?username=pp&amp;password=<span class="number">123456</span> HTTP/<span class="number">1.1</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//--------------------------请求头--------------------------------</span></span><br><span class="line"><span class="comment">// Host:主机地址</span></span><br><span class="line">Host:localhost</span><br><span class="line"><span class="comment">// HTTP1.1版本默认开启，建立过连接后，TCP连接不会断开，下次连接可以继续使用（底层，不用管）</span></span><br><span class="line">Connection: keep-alive</span><br><span class="line"><span class="comment">//chrome浏览器自己增加的，不用管</span></span><br><span class="line">Upgrade-Insecure-Requests: <span class="number">1</span></span><br><span class="line"><span class="comment">//浏览器的代理字符串（版本信息）</span></span><br><span class="line">User-Agent: Mozilla/<span class="number">5.0</span> (Windows NT <span class="number">10.0</span>; WOW64) AppleWebKit/<span class="number">537.36</span> (KHTML, like Gecko) Chrome/<span class="number">58.0</span><span class="number">.3029</span><span class="number">.96</span> Safari/<span class="number">537.36</span></span><br><span class="line"><span class="comment">//浏览器端可以接受的类型。</span></span><br><span class="line">Accept: text/html,application/xhtml+xml,application/xml;q=<span class="number">0.9</span>,image/webp,<span class="string">`*/*`</span>;q=<span class="number">0.8</span></span><br><span class="line"><span class="comment">//从哪个页面发出的请求</span></span><br><span class="line">Referer: http:<span class="comment">//localhost/day02/01-login.html</span></span><br><span class="line"><span class="comment">//检查浏览器支持的压缩方式</span></span><br><span class="line">Accept-Encoding: gzip, deflate, sdch</span><br><span class="line"><span class="comment">//浏览器支持的语言，优先中文。</span></span><br><span class="line">Accept-Language: zh-CN,zh;q=<span class="number">0.8</span>,en;q=<span class="number">0.6</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//----------------------------请求主体-------------------------------------</span></span><br><span class="line"><span class="comment">//get请求没有请求体，因为要传递的数据已经拼接到了请求主头中</span></span><br></pre></td></tr></table></figure>



<p><strong>POST请求的请求报文</strong> </p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//-----------------------请求行---------------------------------------------</span></span><br><span class="line">POST /day02/<span class="number">01.</span>php HTTP/<span class="number">1.1</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//-----------------------请求头--------------------------------------------</span></span><br><span class="line">Host:localhost</span><br><span class="line">Connection: keep-alive</span><br><span class="line"><span class="comment">//传递的参数的长度。</span></span><br><span class="line">Content-Length: <span class="number">29</span></span><br><span class="line">Cache-Control: max-age=<span class="number">0</span> <span class="comment">//禁用缓存</span></span><br><span class="line">Origin: http:<span class="comment">//localhost 响应地址</span></span><br><span class="line">Upgrade-Insecure-Requests: <span class="number">1</span> 允许https协议</span><br><span class="line">User-Agent: Mozilla/<span class="number">5.0</span> (Windows NT <span class="number">10.0</span>; WOW64) AppleWebKit/<span class="number">537.36</span> (KHTML, like Gecko) Chrome/<span class="number">58.0</span><span class="number">.3029</span><span class="number">.96</span> Safari/<span class="number">537.36</span></span><br><span class="line"><span class="comment">//内容类型：表单数据，如果是post请求，必须指定这个属性。</span></span><br><span class="line">Content-Type: application/x-www-form-urlencoded</span><br><span class="line">Accept: text/html,application/xhtml+xml,application/xml;q=<span class="number">0.9</span>,image/webp,<span class="string">`*/*`</span>;q=<span class="number">0.8</span> 可以接受的类型</span><br><span class="line">Referer: http:<span class="comment">//localhost/day02/01-login.html 发送请求的地址</span></span><br><span class="line">Accept-Encoding: gzip, deflate 可以接受的类型</span><br><span class="line">Accept-Language: zh-CN,zh;q=<span class="number">0.8</span>,en;q=<span class="number">0.6</span> 可以接受的语言</span><br><span class="line"></span><br><span class="line"><span class="comment">//------------------------请求体------------------------------------------</span></span><br><span class="line">username=pp&amp;password=<span class="number">123456</span></span><br></pre></td></tr></table></figure>



<p><strong>GET请求与POST请求的对比</strong> </p>
<ul>
<li>GET请求没有请求体，因为GET请求的参数拼接到地址栏中了</li>
<li>POST请求有请求体，就是传递的参数。</li>
</ul>
<h2 id="响应与响应报文"><a href="#响应与响应报文" class="headerlink" title="响应与响应报文"></a>响应与响应报文</h2><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//---------------------状态行（响应行）-------------------------------</span></span><br><span class="line"><span class="comment">//HTTP/1.1  HTTP版本</span></span><br><span class="line"><span class="comment">//200 响应的状态</span></span><br><span class="line">	<span class="comment">//200表示成功</span></span><br><span class="line">	<span class="comment">//302页面重定向</span></span><br><span class="line">	<span class="comment">//304表示文档未修改</span></span><br><span class="line">	<span class="comment">//404表示找不到资源</span></span><br><span class="line">	<span class="comment">//500表示服务端错误</span></span><br><span class="line">HTTP/<span class="number">1.1</span> <span class="number">200</span> OK</span><br><span class="line"></span><br><span class="line"><span class="comment">//----------------------响应头-----------------------------------------------</span></span><br><span class="line"><span class="built_in">Date</span>: Thu, <span class="number">22</span> Jun <span class="number">2017</span> <span class="number">16</span>:<span class="number">51</span>:<span class="number">22</span> GMT <span class="comment">//服务器的时间</span></span><br><span class="line">Server: Apache/<span class="number">2.4</span><span class="number">.23</span> (Win32) OpenSSL/<span class="number">1.0</span><span class="number">.2</span>j PHP/<span class="number">5.4</span><span class="number">.45</span>  <span class="comment">//服务器的版本信息</span></span><br><span class="line">X-Powered-By: PHP/<span class="number">5.4</span><span class="number">.45</span>  <span class="comment">//后台编程语言信息</span></span><br><span class="line">Content-Length: <span class="number">18</span>   <span class="comment">//服务器的响应主体长度</span></span><br><span class="line"><span class="comment">//内容类型，告诉浏览器该如何解析响应结果</span></span><br><span class="line">Content-Type: text/html;charset=utf<span class="number">-8</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//-----------------------响应主体------------------------------------------------</span></span><br><span class="line">用户登录成功</span><br></pre></td></tr></table></figure>

<p>​    通常来说，我们不会用抓包工具来查看请求和响应，太麻烦了，可以直接使用谷歌浏览器来查看请求报文和响应报文。</p>
<p>​    谷歌浏览器会对报文进行一定的格式化，看起来虽然不是原生的报文，但是使用起来更加的方便简洁。</p>
<h1 id="Mysql数据库技术"><a href="#Mysql数据库技术" class="headerlink" title="Mysql数据库技术"></a>Mysql数据库技术</h1><h2 id="初识数据库概念"><a href="#初识数据库概念" class="headerlink" title="初识数据库概念"></a>初识数据库概念</h2><p><strong>数据库基本概念</strong></p>
<blockquote>
<p>专门用来存储、管理数据的仓库（空间），按照数据结构来组织、存储和管理，可以实现高效存取数据。英文：Database, DB。</p>
</blockquote>
<p><strong>关系型数据库</strong></p>
<p>当前使用范围最广的数据库。基于表, 按照关系模型（数据之间表与表存在联系）组织的数据库。</p>
<p>订单：订单编号，商品名称，价格，数量，配送地址</p>
<table>
<thead>
<tr>
<th><strong>订单编号</strong></th>
<th><strong>商品名称</strong></th>
<th><strong>价格</strong></th>
<th><strong>数量</strong></th>
<th><strong>配送地址</strong></th>
</tr>
</thead>
<tbody><tr>
<td>100123</td>
<td>华为mate10</td>
<td>4999</td>
<td>2</td>
<td>北京市京顺路99号</td>
</tr>
<tr>
<td>100124</td>
<td>花裙子</td>
<td>499</td>
<td>1</td>
<td>北京市清华大学1号楼</td>
</tr>
</tbody></table>
<ul>
<li>关系型数据库: 基于表, 表与表之间可以存在关系进行多表查询的存储方式, 适合较为复杂的存储   mysql, SQL Server, oracle</li>
</ul>
<ul>
<li>非关系型 数据库: 基于键值对的存储方式, 数据之间没有耦合性, 特点执行效率高  mongodb</li>
</ul>
<h3 id="数据库的组织架构："><a href="#数据库的组织架构：" class="headerlink" title="数据库的组织架构："></a><strong>数据库的组织架构：</strong></h3><ul>
<li><p><strong>数据表（table）</strong></p>
<p>表是以行和列的形式组织起来的数据的集合。项目一般需要不同的数据表，将数据分布存储在不同的数据表中。</p>
<p>数据库的数据存放在数据表中</p>
<p>如：订单表，用户表，商品表，配送地址表</p>
</li>
</ul>
<ul>
<li><p><strong>记录-行（row，record）</strong></p>
<p>我们把表中的每一行叫做一条“记录”</p>
</li>
</ul>
<ul>
<li><p><strong>字段-列 (column，field)</strong></p>
<p>字段是比记录更小的单位，多个字段集合组成记录, 即数据项</p>
</li>
</ul>
<h3 id="关系型数据库—MySQL"><a href="#关系型数据库—MySQL" class="headerlink" title="关系型数据库—MySQL"></a>关系型数据库—MySQL</h3><blockquote>
<p>数据库官网地址：<a href="https://dev.mysql.com" target="_blank" rel="noopener">https://dev.mysql.com</a></p>
</blockquote>
<blockquote>
<p>英文手册地址：<a href="https://dev.mysql.com/doc/refman/5.5/en/" target="_blank" rel="noopener">https://dev.mysql.com/doc/refman/5.5/en/</a></p>
</blockquote>
<blockquote>
<p>中文参考论坛：<a href="http://www.mysqlpub.com/" target="_blank" rel="noopener">http://www.mysqlpub.com/</a></p>
</blockquote>
<h3 id="SQL-操作数据库的语言"><a href="#SQL-操作数据库的语言" class="headerlink" title="SQL-操作数据库的语言"></a>SQL-操作数据库的语言</h3><p>​    SQL：structured Query Language 结构化查询语言。<br>​    SQL语句，相当于客户端发送的命令（与数据库服务器进行交互）, 我们后面就是要学习 SQL 语句操作数据库</p>
<ul>
<li><p>.sql  数据库脚本语言的后缀。  </p>
</li>
<li><p>主要是执行 数据操作的基本逻辑有：增删改查 操作</p>
</li>
</ul>
<h2 id="数据库操作方式"><a href="#数据库操作方式" class="headerlink" title="数据库操作方式"></a>数据库操作方式</h2><ul>
<li><p>数据库的相关设置： （打开数据库命令行，修改数据库密码等）</p>
<p><img src="E:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/mysqlcmd01.png" alt="">;</p>
</li>
<li><p>命令行演示（了解）<br><img src="E:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/cmd.png" alt=""></p>
<ul>
<li>show databases; 展示所有数据库</li>
<li>use database; 使用某个数据库  use XX;</li>
<li>show tables;展示所有的表</li>
</ul>
</li>
</ul>
<ul>
<li><p>图形界面客户端 </p>
<p>​    <img src="E:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/connect.png" alt=""></p>
</li>
</ul>
<hr>
<h2 id="数据库表的操作"><a href="#数据库表的操作" class="headerlink" title="数据库表的操作"></a>数据库表的操作</h2><h3 id="数据库的数据类型"><a href="#数据库的数据类型" class="headerlink" title="数据库的数据类型"></a>数据库的数据类型</h3><p>字段类型初步介绍</p>
<ul>
<li><p>整型</p>
<p>存储如年龄，产品数量，编号等。 int</p>
</li>
</ul>
<ul>
<li><p>小数类型</p>
<p>float(普通小数，可能会丢失精度)  ,      如. 重量，工资，奖金，价格等</p>
<p>decimal 使用decimal类型，实现小数的精确存储,一般用来存储与钱有关的数字。3.333333331</p>
</li>
<li><p>字符串型</p>
<p>varchar(M)，char(M)  M为该字段可以存储的最多字符数，如varchar(10)。</p>
<p>varchar一般用来存储长度变化比较大的字符串，如文章标题，商品名称，    </p>
<p>char存储长度比较固定的字符串，如手机号，身份证号，序列号，邮编。    </p>
<p>此外可以使用text类型，存储较长的字符串，无需指定字符串的具体长度。</p>
</li>
<li><p>日期时间型</p>
<p>datetime,date(年月日)，time（时分秒）。年月日时分秒。</p>
</li>
</ul>
<p><strong>字段约束</strong></p>
<p>字段约束: 字段数据的属性规则（特征）</p>
<ol>
<li><p>not null 不为空</p>
<p>可以限制字段值不能为空</p>
</li>
<li><p>default  默认值, </p>
<p>可以设置字段的默认值，在没有录入时自动使用默认值填充。</p>
</li>
<li><p>primary key  主键 ：唯一标识，不能重复，不能为空 </p>
<p>设置字段为主键，主键字段的值不能重复，不能为空。而且一个数据表中只能设置一个字段为主键，作为每行记录的唯一身份信息（索引）。stu_id int primary key </p>
</li>
<li><p>auto_increment  自动增长</p>
<p>设置字段为自动增长，默认从1开始自动分配编号。自增长字段必须为一个key（索引，数据结构，便于快速查找数据，相当于书的目录），一般与primary key结合使用。</p>
<p>类型必须为整型。</p>
</li>
<li><p>unique key  不能重复</p>
<p>唯一键，设置字段的值为唯一的，可以设置多个字段为唯一键。唯一键字段的值可以为空。</p>
<p>学号设置为主键，要求唯一的，不能为空的，用来标识学生信息，</p>
</li>
</ol>
<h3 id="创建数据表"><a href="#创建数据表" class="headerlink" title="创建数据表"></a>创建数据表</h3><blockquote>
<p>注意 创建表时，每个表必须有一个主键</p>
</blockquote>
<p><img src="E:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/createtable.png" alt=""></p>
<p>保存表结构：</p>
<p><img src="E:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/savetable.png" alt=""></p>
<p>向新建的表中添加数据：</p>
<p><img src="E:/%E5%89%8D%E7%AB%AF%E8%B5%84%E6%96%99/php-03/%E7%AC%94%E8%AE%B0/img/addtable.png" alt=""></p>
<h3 id="SQL"><a href="#SQL" class="headerlink" title="SQL"></a>SQL</h3><p>SQL编写注意点:  注释用 – , 语句结束加分号(;)</p>
<p><strong>增删改查</strong></p>
<ol>
<li>插入数据 insert</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- insert into 表名 (字段列表) values (值列表)</span></span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> book (<span class="keyword">name</span>,author,<span class="keyword">category</span>,price) <span class="keyword">values</span> (<span class="string">'天龙八部'</span>,<span class="string">'金庸'</span>,<span class="string">'文学'</span>,<span class="number">20</span>)</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>修改数据update</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- update 表名 set 字段名称1=值1,字段名称2=值2,... where 条件</span></span><br><span class="line"><span class="keyword">update</span> book <span class="keyword">set</span> <span class="keyword">name</span>=<span class="string">'笑傲江湖'</span>,price=<span class="string">'30'</span> <span class="keyword">where</span> <span class="keyword">id</span>=<span class="number">10</span></span><br></pre></td></tr></table></figure>

<ol start="3">
<li>删除数据delete</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- delete from 表名 where 条件</span></span><br><span class="line"><span class="keyword">delete</span> <span class="keyword">from</span> book <span class="keyword">where</span> <span class="keyword">id</span>=<span class="number">10</span></span><br></pre></td></tr></table></figure>

<ol start="4">
<li>查询数据select</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- select * from 表名 where 条件</span></span><br><span class="line"><span class="keyword">select</span> * <span class="keyword">from</span> book <span class="keyword">where</span> author=<span class="string">'金庸'</span> <span class="keyword">and</span> price&gt;<span class="number">20</span></span><br></pre></td></tr></table></figure>




<h3 id="SQL高级"><a href="#SQL高级" class="headerlink" title="SQL高级"></a>SQL高级</h3><ol>
<li><p>where子句</p>
<p>查询时，不添加where条件返回数据表所有行。需要添加限定条件，只返回需要的行。</p>
<p>select  字段列表 from  table where子句；</p>
</li>
</ol>
<ol start="2">
<li>Like 模糊匹配  % 通配符</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 查找姓张的人</span></span><br><span class="line"><span class="keyword">select</span> * <span class="keyword">from</span> <span class="keyword">table</span> <span class="keyword">where</span> <span class="keyword">name</span> <span class="keyword">like</span> <span class="string">'张%'</span>;</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>in 语法：一次查询多个符合条件的数据</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span>  字段列表 <span class="keyword">from</span> tb <span class="keyword">where</span>  字段 <span class="keyword">in</span>  (value1,value2,value3);</span><br></pre></td></tr></table></figure>

<ol start="4">
<li>Count() 获取返回数据的总条数</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">-- 查询满足条件数据的总条数	</span></span><br><span class="line"><span class="keyword">select</span> <span class="keyword">count</span>(*) <span class="keyword">from</span> <span class="keyword">table</span> <span class="keyword">where</span> 条件</span><br></pre></td></tr></table></figure>

<ol start="5">
<li><p>limit 子句</p>
<p>返回查找结果中的前 n 行 </p>
</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> 字段列表  <span class="keyword">from</span>  <span class="keyword">table</span> <span class="keyword">limit</span> 截取的起始索引，截取的长度</span><br></pre></td></tr></table></figure>

<ol start="6">
<li>连接查询</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> 字段列表 <span class="keyword">from</span>  A <span class="keyword">join</span> B <span class="keyword">on</span>  A.字段=B.字段 [<span class="keyword">where</span>子句];</span><br></pre></td></tr></table></figure>



<p>​    </p>
<p>创建学生表 ：姓名、年龄、性别</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> <span class="string">`stu`</span> (<span class="keyword">name</span>, age, sex) <span class="keyword">VALUES</span> (<span class="string">'张三'</span>, <span class="string">'18'</span>, <span class="string">'男'</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> <span class="string">`stu`</span> (<span class="keyword">name</span>, age, sex) <span class="keyword">VALUES</span> (<span class="string">'李四'</span>, <span class="string">'19'</span>, <span class="string">'女'</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> <span class="string">`stu`</span> (<span class="keyword">name</span>, age, sex) <span class="keyword">VALUES</span> (<span class="string">'王五'</span>, <span class="string">'22'</span>, <span class="string">'男'</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> <span class="string">`stu`</span> (<span class="keyword">name</span>, age, sex) <span class="keyword">VALUES</span> (<span class="string">'赵六'</span>, <span class="string">'18'</span>, <span class="string">'女'</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> <span class="string">`stu`</span> (<span class="keyword">name</span>, age, sex) <span class="keyword">VALUES</span> (<span class="string">'田七'</span>, <span class="string">'15'</span>, <span class="string">'男'</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> <span class="string">`stu`</span> (<span class="keyword">name</span>, age, sex) <span class="keyword">VALUES</span> (<span class="string">'王八'</span>, <span class="string">'16'</span>, <span class="string">'女'</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> <span class="string">`stu`</span> (<span class="keyword">name</span>, age, sex) <span class="keyword">VALUES</span> (<span class="string">'李狗蛋'</span>, <span class="string">'18'</span>, <span class="string">'男'</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> <span class="string">`stu`</span> (<span class="keyword">name</span>, age, sex) <span class="keyword">VALUES</span> (<span class="string">'李元芳'</span>, <span class="string">'20'</span>, <span class="string">'男'</span>);</span><br><span class="line"><span class="keyword">INSERT</span> <span class="keyword">INTO</span> <span class="string">`stu`</span> (<span class="keyword">name</span>, age, sex) <span class="keyword">VALUES</span> (<span class="string">'张飞'</span>, <span class="string">'16'</span>, <span class="string">'男'</span>);</span><br></pre></td></tr></table></figure>


      
      
        <div class="page-reward">
          <p><a href="javascript:void(0)" onclick="dashangToggle()" class="dashang">赏</a></p>
          <div class="hide_box"></div>
          <div class="shang_box">
            <a class="shang_close" href="javascript:void(0)" onclick="dashangToggle()">×</a>
            <div class="shang_tit">
              <p>纯属好玩</p>
            </div>
            <div class="shang_payimg">
              <img src="/img/alipayimg.jpg" alt="扫码支持" title="扫一扫" />
            </div>
              <div class="pay_explain">扫码打赏，你说多少就多少</div>
            <div class="shang_payselect">
              
                <div class="pay_item checked" data-id="alipay">
                  <span class="radiobox"></span>
                  <span class="pay_logo"><img src="/img/alipay.png" alt="支付宝" /></span>
                </div>
              
              
                <div class="pay_item" data-id="wechat">
                  <span class="radiobox"></span>
                  <span class="pay_logo"><img src="/img/weixin.png" alt="微信" /></span>
                </div>
              
            </div>
            <div class="shang_info">
              <p>打开<span id="shang_pay_txt">支付宝</span>扫一扫，即可进行扫码打赏哦</p>
            </div>
          </div>
        </div>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/zepto/1.2.0/zepto.min.js"></script>
        <script type="text/javascript">
          $(".pay_item").click(function(){
            $(this).addClass('checked').siblings('.pay_item').removeClass('checked');
            var dataid=$(this).attr('data-id');
            $(".shang_payimg img").attr("src","/img/"+dataid+"img.jpg");
            $("#shang_pay_txt").text(dataid=="alipay"?"支付宝":"微信");
          });
          function dashangToggle(){
            
            $(".hide_box").fadeToggle();
            $(".shang_box").fadeToggle();
          }
        </script>
      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/2019/05/06/PHP%E7%9B%B8%E5%85%B3/">PHP相关</a></p>
        <p><span>文章作者:</span><a href="/" title="访问 程序猿 的个人博客">程序猿</a></p>
        <p><span>发布时间:</span>2019年05月06日 - 00时00分</p>
        <p><span>最后更新:</span>2020年05月19日 - 09时07分</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/2019/05/06/PHP%E7%9B%B8%E5%85%B3/" title="PHP相关">http://yoursite.com/2019/05/06/PHP%E7%9B%B8%E5%85%B3/</a>
            <span class="copy-path" data-clipboard-text="原文: http://yoursite.com/2019/05/06/PHP%E7%9B%B8%E5%85%B3/　　作者: 程序猿" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script src="/js/clipboard.min.js"></script>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license noopener" href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" target="_blank" title="中国大陆 (CC BY-NC-SA 3.0 CN)" target = "_blank">"署名-非商用-相同方式共享 3.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



<nav id="article-nav">
  
    <a href="/2019/10/10/%E7%A7%BB%E5%8A%A8%E7%AB%AF%E5%BC%80%E5%8F%91%E5%9F%BA%E7%A1%80/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption"><</strong>
      <div class="article-nav-title">
        
          移动端开发基础
        
      </div>
    </a>
  
  
    <a href="/2019/03/10/git%E4%B8%8Egithub%E4%BD%BF%E7%94%A8/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">git与github使用</div>
      <strong class="article-nav-caption">></strong>
    </a>
  
</nav>

  
</article>

    <div id="toc" class="toc-article">
    <strong class="toc-title">文章目录</strong>
    <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#学生信息管理系统"><span class="toc-number">1.</span> <span class="toc-text">学生信息管理系统</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#基本功能"><span class="toc-number">1.0.1.</span> <span class="toc-text">基本功能</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#实现思路"><span class="toc-number">1.0.2.</span> <span class="toc-text">实现思路</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#HTTP协议"><span class="toc-number">2.</span> <span class="toc-text">HTTP协议</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#请求报文和响应报文"><span class="toc-number">2.0.1.</span> <span class="toc-text">请求报文和响应报文</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#响应与响应报文"><span class="toc-number">2.1.</span> <span class="toc-text">响应与响应报文</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Mysql数据库技术"><span class="toc-number">3.</span> <span class="toc-text">Mysql数据库技术</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#初识数据库概念"><span class="toc-number">3.1.</span> <span class="toc-text">初识数据库概念</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#数据库的组织架构："><span class="toc-number">3.1.1.</span> <span class="toc-text">数据库的组织架构：</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#关系型数据库—MySQL"><span class="toc-number">3.1.2.</span> <span class="toc-text">关系型数据库—MySQL</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SQL-操作数据库的语言"><span class="toc-number">3.1.3.</span> <span class="toc-text">SQL-操作数据库的语言</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#数据库操作方式"><span class="toc-number">3.2.</span> <span class="toc-text">数据库操作方式</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#数据库表的操作"><span class="toc-number">3.3.</span> <span class="toc-text">数据库表的操作</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#数据库的数据类型"><span class="toc-number">3.3.1.</span> <span class="toc-text">数据库的数据类型</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#创建数据表"><span class="toc-number">3.3.2.</span> <span class="toc-text">创建数据表</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SQL"><span class="toc-number">3.3.3.</span> <span class="toc-text">SQL</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#SQL高级"><span class="toc-number">3.3.4.</span> <span class="toc-text">SQL高级</span></a></li></ol></li></ol></li></ol>
</div>
<input type="button" id="tocButton" value="隐藏目录"  title="点击按钮隐藏或者显示文章目录">


<script src="https://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>

<script>
    var valueHide = "隐藏目录";
    var valueShow = "显示目录";

    if ($(".left-col").is(":hidden")) {
        $("#tocButton").attr("value", valueShow);
    }
    $("#tocButton").click(function() {
        if ($("#toc").is(":hidden")) {
            $("#tocButton").attr("value", valueHide);
            $("#toc").slideDown(320);
        }
        else {
            $("#tocButton").attr("value", valueShow);
            $("#toc").slideUp(350);
        }
    })
    if ($(".toc").length < 1) {
        $("#toc, #tocButton").hide();
    }
</script>





<div class="bdsharebuttonbox">
	<a href="#" class="fx fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
	<a href="#" class="fx fa-weixin bds_weixin" data-cmd="weixin" title="分享到微信"></a>
	<a href="#" class="fx fa-qq bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
	<a href="#" class="fx fa-facebook-official bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
	<a href="#" class="fx fa-twitter bds_twi" data-cmd="twi" title="分享到Twitter"></a>
	<a href="#" class="fx fa-linkedin bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a>
	<a href="#" class="fx fa-files-o bds_copy" data-cmd="copy" title="分享到复制网址"></a>
</div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"2","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>




    
        <section id="comments">
  <div id="disqus_thread"></div>
    <script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'swing'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
  </script>
  <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" target="_blank" rel="noopener">comments powered by Disqus.</a></noscript>
</section>
    



    <div class="scroll" id="post-nav-button">
        
            <a href="/2019/10/10/%E7%A7%BB%E5%8A%A8%E7%AB%AF%E5%BC%80%E5%8F%91%E5%9F%BA%E7%A1%80/" title="上一篇: 移动端开发基础">
                <i class="fa fa-angle-left"></i>
            </a>
        
        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>
        
            <a href="/2019/03/10/git%E4%B8%8Egithub%E4%BD%BF%E7%94%A8/" title="下一篇: git与github使用">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>
    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2020/05/19/CSS3/">CSS3</a></li><li class="post-list-item"><a class="post-list-link" href="/2020/01/05/VUE%E7%9B%B8%E5%85%B3/">VUE相关</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/12/05/es6%E7%9B%B8%E5%85%B3/">es6相关</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/10/10/%E7%A7%BB%E5%8A%A8%E7%AB%AF%E5%BC%80%E5%8F%91%E5%9F%BA%E7%A1%80/">移动端开发基础</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/05/06/PHP%E7%9B%B8%E5%85%B3/">PHP相关</a></li><li class="post-list-item"><a class="post-list-link" href="/2019/03/10/git%E4%B8%8Egithub%E4%BD%BF%E7%94%A8/">git与github使用</a></li><li class="post-list-item"><a class="post-list-link" href="/2018/12/10/ajax/">ajax</a></li></ul>
    <script src="https://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
    <script>
        $(".post-list").addClass("toc-article");
        $(".post-list-item a").attr("target","_blank");
        $("#post-nav-button > a:nth-child(2)").click(function() {
            $(".fa-bars, .fa-times").toggle();
            $(".post-list").toggle(300);
            if ($(".toc").length > 0) {
                $("#toc, #tocButton").toggle(200, function() {
                    if ($(".switch-area").is(":visible")) {
                        $("#tocButton").attr("value", valueHide);
                        }
                    })
            }
            else {
            }
        })
    </script>



    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                &copy; 2020 程序猿
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="http://bestwing.me" target="_blank">Sw'blog</a> by Swing
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" >海贼到访数: 
                            <span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>, </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit">本页阅读量: 
                            <span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>

    </div>
    
<script src="https://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>


<script src="/js/main.js"></script>


    <script>
        $(document).ready(function() {
            var backgroundnum = 24;
            var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
            $("#mobile-nav").css({"background-image": backgroundimg,"background-size": "cover","background-position": "center"});
            $(".left-col").css({"background-image": backgroundimg,"background-size": "cover","background-position": "center"});
        })
    </script>





<div class="scroll" id="scroll">
    <a href="#"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments"><i class="fa fa-comments-o"></i></a>
    <a href="#footer"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    $(document).ready(function() {
        if ($("#comments").length < 1) {
            $("#scroll > a:nth-child(2)").hide();
        };
    })
</script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

  <script language="javascript">
    $(function() {
        $("a[title]").each(function() {
            var a = $(this);
            var title = a.attr('title');
            if (title == undefined || title == "") return;
            a.data('title', title).removeAttr('title').hover(

            function() {
                var offset = a.offset();
                $("<div id=\"anchortitlecontainer\"></div>").appendTo($("body")).html(title).css({
                    top: offset.top - a.outerHeight() - 15,
                    left: offset.left + a.outerWidth()/2 + 1
                }).fadeIn(function() {
                    var pop = $(this);
                    setTimeout(function() {
                        pop.remove();
                    }, pop.text().length * 800);
                });
            }, function() {
                $("#anchortitlecontainer").remove();
            });
        });
    });
</script>


    <script type="text/javascript">
      window.onload = function(){
        document.getElementById("search").onclick = function(){
            console.log("search")
            search();
        }
      }
      function search(){
        (function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
        (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
        e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
        })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

        _st('install','A1Pz-LKMXbrzcFg2FWi6','2.0.0');
      }
    </script>

  </div>
</body>
</html>